import http from '@/util/request.js'

export default {
    // 根据id获取订单地址信息
    getOrderAddrById: (id) => {
        return http({
            url: `/api/order/addr/id/${id}`,
            method: 'get'
        })
    },

    // 根据用户id获取订单地址列表
    getOrderAddrsByUserId: (userId) => {
        return http({
            url: `/api/order/addr/user/${userId}`,
            method: 'get'
        })
    },

    // 根据秒杀商品id获取订单地址列表
    getOrderAddrsBySeckillGoodsId: (seckillGoodsId) => {
        return http({
            url: `/api/order/addr/seckillgoods/${seckillGoodsId}`,
            method: 'get'
        })
    },

    // 根据商品id获取订单地址列表
    getOrderAddrsByGoodsId: (goodsId) => {
        return http({
            url: `/api/order/addr/goods/${goodsId}`,
            method: 'get'
        })
    },

    // 添加订单地址
    addOrderAddr: (data) => {
        return http({
            url: '/api/order/addr/add',
            method: 'post',
            data
        })
    },

    // 更新订单地址
    updateOrderAddr: (data) => {
        return http({
            url: '/api/order/addr/update',
            method: 'put',
            data
        })
    },

    // 删除订单地址（软删除）
    deleteOrderAddr: (id) => {
        return http({
            url: `/api/order/addr/delete/${id}`,
            method: 'delete'
        })
    },

    // 获取订单地址列表
    getOrderAddrList: (data) => {
        return http({
            url: '/api/order/addr/list',
            method: 'get',
            params: data
        })
    },

    // 获取订单地址分页列表
    getOrderAddrPage: (current, size, data) => {
        return http({
            url: '/api/order/addr/page',
            method: 'get',
            params: {
                current: current,
                size: size,
                ...data
            }
        })
    }
}
